/*
Copyright (C) 2013-2021 LZE
Hungarian Algorithm
*/
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define mod 1000000007
#define eps 1e-6
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=10010;
const int M=1050;
ll n,m,e;

bool link[N][N] = {0};

ll vis[N] = {0},nxt[N] = {0};

bool Match(ll p){
    for(ll i = 1;i <= m;i++){
        if(link[p][i] && !vis[i]){
            vis[i] = true;
            if(nxt[i] == 0 || Match(nxt[i])){
                nxt[i] = p;
                return true;
            }
        }
    }
    return false;
}
ll Hungarian_Algorithm(){
    ll ans = 0;
    for(ll i = 1;i <= n;i++){
        memset(vis,0,sizeof(vis));
        if(Match(i))ans++;
    }
    return ans;
}
int main() {
	scanf("%lld%lld%lld",&n,&m,&e);
    ll u,v;
    for(ll i = 1;i <= e;i++){
        scanf("%lld%lld",&u,&v);
        link[u][v] = true;
    }
    printf("%lld",Hungarian_Algorithm());
	return 0;
}
